{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin static %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block title %}Chartering or re-chartering groups{% endblock %}
{% block content %}
    {% origin %}
    {% load ietf_filters %}
    {% load ballot_icon %}
    <h1>Chartering or re-chartering groups</h1>
    <p>
        Groups with a charter in one of the following states:
    </p>
    <ul>
        {% for s in charter_states %}<li>{{ s.name }}</li>{% endfor %}
    </ul>
    {% for t in group_types %}
        <h2 class="mt-3">{{ t.name }}s</h2>
        {% if t.can_manage %}
            <p>
                <a class="btn btn-primary"
                   role="button"
                   href="{% url 'ietf.group.views.edit' group_type=t.pk action='charter' %}">
                    Charter new {{ t.name }}
                </a>
            </p>
        {% endif %}
        {% if not t.chartering_groups %}
            <p>
                Found no groups in a chartering state.
            </p>
        {% else %}
            <table class="table table-sm table-striped tablesorter">
                <thead>
                    <tr>
                        <th scope="col" data-sort="acronym">{{ t.name }}</th>
                        <th scope="col" data-sort="name">Name</th>
                        <th scope="col" data-sort="date">Date</th>
                        <th scope="col" data-sort="status">Status</th>
                    </tr>
                </thead>
                <tbody>
                    {% for g in t.chartering_groups %}
                        <tr>
                            <td>
                                <a href="{{ g.about_url }}">{{ g.acronym }}</a>
                            </td>
                            <td>
                                <a href="{% url "ietf.doc.views_doc.document_main" name=g.charter.name %}">{{ g.name }}</a>
                            </td>
                            <td>{{ g.charter.time|date:"Y-m-d" }}</td>
                            <td>
                                <div class="float-end">{% ballot_icon g.charter %}</div>
                                {{ g.charter.get_state.name }}
                                {% if g.chartering_type == "initial" %}(Initial Chartering){% endif %}
                                {% if g.chartering_type == "recharter" %}(Rechartering){% endif %}
                                {% if not g.chartering_type and g.state_id != "active" %}({{ g.state.name }}){% endif %}
                                {% if g.charter.telechat_date %}
                                    <br>
                                    IESG Telechat: {{ g.charter.telechat_date|date:"Y-m-d" }}
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% endif %}
    {% endfor %}
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}